<?php
class Shop_Form_HasCategory_Add extends Promotor_Form_Scaffold {
	public function init() {
		$this->setMethod('post');
		$this->setAttrib('enctype', Zend_Form::ENCTYPE_MULTIPART);

		$this->addPrefixPath('Promotor_Form_Decorator_','Promotor/Form/Decorator', self::DECORATOR);
        
		$subForm = $this->_getContentForm();
        $this->addSubForm($subForm, 'contenttab');
	}
	

	/**
     * @return Zend_Dojo_Form_SubForm
     */
    protected function _getContentForm() {
    	$subForm = new Zend_Form_SubForm();
        $subForm->setAttribs(array(
            'name'   => 'contenttab',
            'legend' => 'Atrybut',
        ));
        $subForm
        	->addElement(new KontorX_Form_Element_Db_Select('product_id', array(
            	'label' => 'Produkt',
                'description' => 'Wybierz produkt',
            	'required' => true,
            	'tableName' => 'shop_product',
            	'tableCols' => array('key' => 'id','value' => 'name')
            )))
            ->addElement(new KontorX_Form_Element_Db_SelectTree('category_id', array(
            	'label' => 'Kategoria',
                'description' => 'Wybierz kategorię',
            	'required' => true,
            	'dbTable' => 'Shop_Model_DbTable_HasCategory',
            	'optionKey' => 'name',
            	'optionValue' => 'id',
            
//            	'dbTable' => 'Site_Model_DbTable_Site',
//        		'optionKey'  => 'id',
//        		'optionValue'  => 'name',
            
//            	'tableName' => 'shop_category',
//            	'tableCols' => array('key' => 'id','value' => 'name')
            )))
            ->addElement(
                'text',
                'idx',
                array(
                    'label' => 'Domyślna wartość',
                	'description' => 'Kolejność atrybutu; wartość bardziej ujemna to proukt jest wyżej w spisie im wartość bardziej dodatnia tym niżej w spisie',
                	'validators' => array('Int')
                )
            );

        return $subForm;
    }
}